#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time      :2022/6/2 15:01
# @Author    :cjw
import allure
from appium.webdriver.common.appiumby import AppiumBy

from app_wework.base.base_page import BasePage
from app_wework.util.log import logger


class EditMemberPage(BasePage):
	"""手动添加成员页面"""

	__INPUT_NAME = (AppiumBy.XPATH, '//*[contains(@text, "姓名")]/../*[@text="必填"]')  # 姓名
	__INPUT_PHONE = (AppiumBy.XPATH, '//*[contains(@text, "手机")]/..//*[@text="必填"]')  # 手机
	__BTN_SAVE = (AppiumBy.XPATH, '//*[@text="保存"]')  # 保存
	__RADIO_BTN_SEND_MESSAGE = (AppiumBy.XPATH, '//*[contains(@text, "自动发送邀请")]')  # 保存后自动发送邀请通知

	def edit_member_quick_input(self, name: str, phone: str):
		"""
		编辑添加成员，快速输入
		:param name: 姓名
		:param phone: 手机
		:return:
		"""
		from app_wework.page.add_member_page import AddMemberPage

		with allure.step(msg := f'快速添加成员，姓名：{name}，手机：{phone}'):
			logger.info(msg)
			self.find_send_keys(self.__INPUT_NAME, name)
			self.find_send_keys(self.__INPUT_PHONE, phone)
			self.find_click(self.__RADIO_BTN_SEND_MESSAGE)
			self.find_click(self.__BTN_SAVE)
		return AddMemberPage(self.driver)
